<template>
	<view>

		<u-grid :col="col" :border="true" class=" bg_wrap">
			<u-grid-item class="p15" v-for="(item,index) in list.filter(item=>item.show == true)" :key="index"
				@click="btnMyTask(item.type)">
				<u-badge v-show="item.badge" :value="DBCount" :absolute="true" :offset="[10,50]"></u-badge>
				<faicon :type="item.icon" :size="35" :color="bgIconColor"></faicon>
				<view class="grid-text pt10">{{item.name}}</view>
			</u-grid-item>
		</u-grid>


		<button type="default" @click="toPageDemo('list')">toList</button>
		<button type="default" @click="toPageDemo('form')">toForm</button>

		<u-grid :border="true" class="bg_wrap m10 border_radius_shadow" v-if="dataList.length">
			<!-- <view class="w100p fwb f16 mb5">综合管理——信息公告</view> -->
			<u-grid-item @click="toPage(item)" class="p15" v-for="(item,inex) in dataList" :key="inex">
				<faicon :type="item.iconCls" :size="35" :color="bgIconColor"></faicon>
				<text class="grid-text pt10 ellipsis2">{{item.text}}</text>
			</u-grid-item>

			<u-grid-item v-if="dataList.length % 3 ==1" class="p15 u-border-right">
				<text class="grid-ht"></text>
			</u-grid-item>

			<u-grid-item v-if="dataList.length % 3 ==2" class="p15">
				<text class="grid-ht"></text>
			</u-grid-item>
		</u-grid>





	</view>
</template>

<script>
	import faicon from '../components/kilvn-fa-icon/fa-icon.vue'
	export default {
		components: {
			faicon
		},
		data() {
			return {
				list: [{
					name: "我的待办",
					icon: "fa-clock-o",
					type: "Db",
					badge: true,
					show: true
				}, {
					name: "我的已办",
					icon: "fa-calendar-check-o",
					type: "Yb",
					badge: false,
					show: true
				}, {
					name: "我的督办",
					icon: "fa-pencil-square-o",
					type: "Dub",
					badge: false,
					show: false
				}, {
					name: "我的阅办",
					icon: "fa-file-text-o",
					type: "Yueb",
					badge: false,
					show: false
				}],
				col: 2,
				show: false,
				dataList: [],
				bgIconColor: "#2795D3",
				DBCount: 0,
			}
		},
		onReady() {
			this.getData();

			this.getDBCount();
		},
		// onShow() {
		// 	this.getDBCount()
		// },
		methods: {
			getDBCount() {
				//获取待办数量
				this.$api.myAjaxFunc(Config.PlatformAPI + publicJs.Config.WorkFlowRun
					.GetMyTaskDBGroup, {
						SiteID: Common.Const.Site.SiteID,
						IsPC: "0"
					}).then(res => {
					if (res.success) {
						let count = 0;
						res.resultData.filter((item) => {
							count += parseInt(item.allcount);
						})

						this.DBCount = count;
					}
				})
			},
			getData() {

				//获取菜单
				this.$api.myAjaxFunc(Config.PlatformAPI + publicJs.Config.IndexUrl.GetMenu, {
					key: Common.Const.Site.SiteID,
					ispc: "0"
				}).then(res => {
					this.dataList = res;
					console.log(res);
				})

			},
			toPage(e) {

				uni.navigateTo({
					url: e.url
				})

			},
			btnMyTask(param) {

				uni.navigateTo({
					url: "/pages/task/TaskGroup?pageData=" + param
				})

			},
			toPageDemo(param) {

				const url = param == 'list' ? "/pages/list" : "/pages/form"

				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>


<style lang="scss" scoped>
	.grid-text {
		font-size: 14px;
		font-weight: 800;
		// max-width: 110px;
		// white-space: nowrap;
		// overflow: hidden;
		// text-overflow: ellipsis;
		text-align: center;
	}

	.ellipsis2 {
		height: 38px;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.grid-ht {
		height: 83px;
	}
</style>
